package com.hjq.fcloud.widget

import android.content.Context
import android.text.TextUtils
import android.util.AttributeSet
import android.widget.ImageView
import com.hjq.fcloud.R
import com.hjq.fcloud.config.FlowStatusConfig
import com.hjq.fcloud.http.api.FlowStatusApi

/**
 * 签约结果
 */
class SignResultImageView : ImageView {
    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context, attrs, defStyleAttr
    )

    constructor(
        context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int
    ) : super(context, attrs, defStyleAttr, defStyleRes)

    /**
     * 签约状态
     */
    fun setViewData(flowStatusData: FlowStatusApi.FlowStatusData?) {
        FlowStatusConfig.judgeSignSuccess(flowStatusData)?.let { succcess ->
            if (succcess) {
                setImageResource(R.drawable.ic_sign_success)
            } else {
                setImageResource(R.drawable.ic_sign_fail)
            }
        }
    }

}